// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

import { LineEdit } from "std-widgets.slint";

export component TestCase inherits Window {

    callback focus_the_line_edit;
    focus_the_line_edit => {
        le.focus();
    }
    callback focus_the_focus_scope;
    focus_the_focus_scope => {
        fs.focus();
    }

    callback set_manual(bool);
    set_manual(v) => {
        TextInputInterface.text-input-focused = v;
    }

    le := LineEdit {  }
    fs := FocusScope { }

    out property<bool> focused: TextInputInterface.text-input-focused;

}

/*
```rust
let instance = TestCase::new().unwrap();
assert!(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert!(instance.get_focused());
instance.invoke_focus_the_focus_scope();
assert!(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert!(instance.get_focused());
instance.invoke_set_manual(false);
assert!(!instance.get_focused());
instance.invoke_focus_the_focus_scope();
assert!(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert!(instance.get_focused());
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert(instance.get_focused());
instance.invoke_focus_the_focus_scope();
assert(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert(instance.get_focused());
instance.invoke_set_manual(false);
assert(!instance.get_focused());
instance.invoke_focus_the_focus_scope();
assert(!instance.get_focused());
instance.invoke_focus_the_line_edit();
assert(instance.get_focused());
```

```js
var instance = new slint.TestCase();
assert(!instance.focused);
instance.focus_the_line_edit();
assert(instance.focused);
instance.focus_the_focus_scope();
assert(!instance.focused);
instance.focus_the_line_edit();
assert(instance.focused);
instance.set_manual(false);
assert(!instance.focused);
instance.focus_the_focus_scope();
assert(!instance.focused);
instance.focus_the_line_edit();
assert(instance.focused);
```
*/
